<template>
  <div>
    <div>num:{{ plusNum }}</div>
    <div>num:{{ plusNum }}</div>
    <div>msg:{{ reverseMessage() }}</div>
    <div>msg:{{ reverseMessage() }}</div>
  </div>

</template>

<script>
export default {
  name: "TestComputed",
  data() {
    return {
      msg: 'Nihao',
      num: 100
    }
  },
  /* 定义计算属性*/
  methods: {
    reverseMessage: function () {
      console.log('methods')
      return this.msg.split('').reverse().join('');
    }
  },
  computed: {
    plusNum: function () {
      console.log('computed')
      let total = 0;
      for (let i = 0; i <= this.num; i++) {
        total += i;
      }
      return total;
    }
  }
}
</script>

<style scoped>

</style>
